--' Находится ли уже смарткавер в нужном состоянии class "eva_state_mgr_smartcover" (property_evaluator) function eva_state_mgr_smartcover:__init(name, st) super (nil, name) self.st = st end function eva_state_mgr_smartcover:evaluate() if self.st.target_state ~= "smartcover" then return true end local st = db.storage[self.object:id()] local state_descr = st and st["smartcover"] local dest_smart_cover_name = state_descr and self.object:get_dest_smart_cover_name() if not dest_smart_cover_name then return true end return dest_smart_cover_name == (state_descr.cover_name or "") end --' Нужно ли нам входить в смарткавер class "eva_state_mgr_smartcover_need" (property_evaluator) function eva_state_mgr_smartcover_need:__init(name, st) super (nil, name) self.st = st end function eva_state_mgr_smartcover_need:evaluate() if self.st.target_state ~= "smartcover" then return false end local state_descr = db.storage[self.object:id()]["smartcover"] if state_descr == nil then return false end return state_descr.cover_name ~= nil end --' залочена ли схема (находимся ли мы в процессе входа-выхода из смарткавера) class "eva_state_mgr_smartcover_locked" (property_evaluator) function eva_state_mgr_smartcover_locked:__init(name, st) super (nil, name) self.st = st end function eva_state_mgr_smartcover_locked:evaluate() local st = db.storage[self.object:id()] local state_descr = st and st["smartcover"] if state_descr == nil then return false end local in_smart_cover = self.object:in_smart_cover() return (in_smart_cover and state_descr.cover_name == nil) or (not in_smart_cover and state_descr.cover_name ~= nil) end --' залочена ли схема (находимся ли мы в процессе входа-выхода из смарткавера) class "eva_state_mgr_in_smartcover" (property_evaluator) function eva_state_mgr_in_smartcover:__init(name, st) super (nil, name) self.st = st end function eva_state_mgr_in_smartcover:evaluate() return self.object:in_smart_cover() or false end --' Вход в смарткавер class "act_state_mgr_smartcover_enter" (action_base) function act_state_mgr_smartcover_enter:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_smartcover_enter:initialize() action_base.initialize(self) --self.move_mgr:finalize() --self.move_mgr = db.storage[npc:id()].move_mgr local state_descr = db.storage[self.object:id()]["smartcover"] printf("setting smartcover [%s] for stalker [%s] ", tostring(state_descr.cover_name), self.object:name()) self.object:use_smart_covers_only(true) self.object:set_movement_type(move.run) self.object:set_dest_smart_cover(state_descr.cover_name) if state_descr.loophole_name ~= nil then printf("setting smartcover1 [%s] loophole [%s] for stalker [%s] ", tostring(state_descr.cover_name), state_descr.loophole_name, self.object:name()) self.object:set_dest_loophole(state_descr.loophole_name) end end function act_state_mgr_smartcover_enter:execute() action_base.execute(self) end function act_state_mgr_smartcover_enter:finalize() action_base.finalize(self) end --' Выход из смарткавера class "act_state_mgr_smartcover_exit" (action_base) function act_state_mgr_smartcover_exit:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_smartcover_exit:initialize() action_base.initialize(self) local object = self.object object:set_smart_cover_target() object:use_smart_covers_only(false) object:set_smart_cover_target_selector() local vertex = object:level_vertex_id() utils_obj.send_to_nearest_accessible_vertex(object,vertex,"smart_cover_exit") end function act_state_mgr_smartcover_exit:execute() action_base.execute(self) end function act_state_mgr_smartcover_exit:finalize() action_base.finalize(self) end